import unittest
from parameterized import parameterized
from config import BASE_DIR
from common.read_json_data import build_data
import logging
from api.login_api import LoginApi
from common.verify_result import common_assert

class TestLogin(unittest.TestCase):
    @parameterized.expand(build_data(BASE_DIR+'/data/login.json'))
    def test_login(self,desc,body,expect_result):
        print(desc)
        print(f'请求参数为{body}')
        logging.info(f'请求参数为{body}')
        print(f'预期结果为{expect_result}')
        logging.info(f'预期结果为{expect_result}')

        login_obj = LoginApi()
        resp = login_obj.login(body)
        json_data = resp.json()
        print(f'登录结果为{json_data}')

        common_assert(self,expect_result,resp)

